package primeFactors;


import java.util.ArrayList;

/**
 * Created by twer on 9/29/14.
 */
public class PrimeFactors {
    static ArrayList<Integer> generate(int n){
        ArrayList<Integer> factors = new ArrayList<Integer>();
        if (n < 2)
            return factors;
        int i = 2;
        while(i <= n){
            while(n % i == 0){
                n = n / i;
                factors.add(i);
            }
            i++;
        }
        return factors;
   }

   public static void main(String[] args){
       ArrayList<Integer> result = generate(30);
       System.out.print(result);
   }
}
